﻿using Eleven_Threety_RK.BLL;
using Eleven_Threety_RK.DAL;
using Eleven_Threety_RK.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Eleven_Threety_RK.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UserController : ControllerBase
    {
        private readonly ILogger<UserController> _logger;
        public UserBll userBll;
        public UserController(UserBll _userBll, ILogger<UserController> logger)
        {
            userBll = _userBll;
            _logger = logger;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="G"></param>
        /// <returns></returns>
        [HttpPost]
        public int UserAdd(UserInfo G)
        {
            try
            {
                return userBll.UserAdd(G);
            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="UserName"></param>
        /// <param name="Password"></param>
        /// <returns></returns>
        [HttpGet]
        public dynamic UserLog(string UserName, string Password)
        {
            try
            {
                return userBll.UserLog(UserName, Password);
            }
            catch (Exception)
            {
                _logger.LogInformation("用户" + UserName + "登录失败");
                throw;
            }
        }
    }
}
